/**
 * 
 */
package org.lanqiao.netctoss.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;




/**
 * @author Administrator
 *
 */
public class GetSession {
	static SqlSession session = null;
	public static SqlSession getSession(){
		InputStream is;
		try {
			is = Resources.getResourceAsStream("Mybatis_config.xml");
			SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);
			session = build.openSession();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			return session;
		}
	}
	public static void close(){
		if(session!=null) 
			session.close();		
	}
}
